/**
 * Copyleft (C) 2023-2024 maminjie <canpool@163.com>
 * SPDX-License-Identifier: BSD-3-Clause
 **/
#ifndef QXMATERIALAUTOCOMPLETE_P_H
#define QXMATERIALAUTOCOMPLETE_P_H

#include "matautocomplete.h"
#include "mattextfield_p.h"
#include <QStateMachine>

class QWidget;
class QVBoxLayout;

QX_MATERIAL_BEGIN_NAMESPACE

class MatAutoCompleteOverlay;
class MatAutoCompleteStateMachine;

class MatAutoCompletePrivate : public MatTextFieldPrivate
{
    Q_DISABLE_COPY(MatAutoCompletePrivate)
    Q_DECLARE_PUBLIC(MatAutoComplete)
public:
    MatAutoCompletePrivate(MatAutoComplete *q);
    virtual ~MatAutoCompletePrivate();

    void init();

    QWidget *menu;
    QWidget *frame;
    MatAutoCompleteStateMachine *stateMachine;
    QVBoxLayout *menuLayout;
    QStringList dataSource;
    int maxWidth;
};

class MatAutoCompleteStateMachine : public QStateMachine
{
    Q_OBJECT
public:
    explicit MatAutoCompleteStateMachine(QWidget *menu);
    ~MatAutoCompleteStateMachine();

signals:
    void shouldOpen();
    void shouldClose();
    void shouldFade();
private:
    Q_DISABLE_COPY(MatAutoCompleteStateMachine)

    QWidget *const m_menu;
    QState *const m_closedState;
    QState *const m_openState;
    QState *const m_closingState;
};

QX_MATERIAL_END_NAMESPACE

#endif   // QXMATERIALAUTOCOMPLETE_P_H
